A serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time. This is in contrast to a parallel port, which communicates multiple bits simultaneously in parallel. Throughout most of the history of personal computers, data has been transferred through serial ports to devices such as , terminals, various , and directly between computers.
While interfaces such as Ethernet, FireWire, and USB also send data as a serial stream, the term serial port usually denotes hardware compliant with RS-232 or a related standard, such as RS-485 or RS-422.
Modern consumer personal computers (PCs) have largely replaced serial ports with higher-speed standards, primarily USB. However, serial ports are still frequently used in applications demanding simple, low-speed interfaces, such as industrial automation systems, scientific instruments, point of sale systems and some industrial and consumer products.
Server computers may use a serial port as a control console for diagnostics, while networking hardware (such as routers and Network switch) commonly use serial console ports for configuration, diagnostics, and emergency maintenance access. To interface with these and other devices, USB-to-serial converters can quickly and easily add a serial port to a modern PC.
Very low-cost systems, such as some early , would instead use the CPU to send the data through an output pin, using the bit banging technique. These early home computers often had proprietary serial ports with pinouts and voltage levels incompatible with RS-232.
Before large-scale integration (LSI) made UARTs common, serial ports were commonly used in and , which would have multiple small-scale integrated circuits to implement shift registers, logic gates, counters, and all the other logic needed. As PCs evolved serial ports were included in the Super I/O chip and then in the chipset.
Conventionally, computers and terminals are DTE, while peripherals such as are DCE. If it is necessary to connect two DTE (or DCE) devices together, a cable with reversed TX and RX lines, known as a Crossover cable, roll-over or null modem cable must be used.
Connectors mounted on DTE are likely to be male, and those mounted on DCE are likely to be female (with the cable connectors being the opposite). However, this is far from universal; for instance, most serial printers have a female DB25 connector, but they are DTEs. In this circumstance, the appropriately gendered connectors on the cable or a gender changer can be used to correct the mismatch.
The 9-pin D-subminiature connector has been used by most IBM-compatible PCs since the Serial/Parallel Adapter option for the PC-AT, where the 9-pin connector allowed a serial and parallel port to fit on the same card. This connector has been standardized for RS-232 as TIA-574.
Some miniaturized electronics, particularly graphing calculators and hand-held Amateur radio and two-way radio equipment, have serial ports using a phone connector, usually the smaller 2.5 or 3.5 mm connectors and the most basic 3-wire interface—transmit, receive and ground.
8P8C connectors are also used in many devices. The EIA/TIA-561 standard defines a pinout using this connector, while the rollover cable (or Yost standard) is commonly used on Unix computers and network devices, such as equipment from Cisco Systems.
Many models of Macintosh favor the related RS-422 standard, mostly using circular mini-DIN connectors. The Macintosh included a standard set of two ports for connection to a printer and a modem, but some PowerBook laptops had only one combined port to save space.
10P10C connectors can be found on some devices.
Another common connector is a pin header common on motherboards and add-in cards which is usually converted via a ribbon cable to the more standard 9-pin DE-9 connector (and frequently mounted on a free slot plate or other part of the housing).
TxD | 5 |
RxD | 6 |
DTR | 9 |
DCD | 10 |
DSR | 2 |
RI | 1 |
RTS | 3 |
CTS | 8 |
G | 7 |
PG | 4 |
Signal Ground is a common return for the other connections; it appears on two pins in the Yost standard but is the same signal. The DB-25 connector includes a second Protective Ground on pin 1, which is intended to be connected by each device to its own frame ground or similar. Connecting Protective Ground to Signal Ground is a common practice but not recommended.
Note that EIA/TIA 561 combines DSR and RI, and the Yost standard combines DSR and DCD.
Unix-like operating systems usually label the serial port devices . TTY is a common trademark-free abbreviation for teletype, a device commonly attached to early computers' serial ports, and represents a string identifying the specific port; the syntax of that string depends on the operating system and the device. On Linux, 8250/16550 UART hardware serial ports are named , USB adapters appear as and various types of virtual serial ports do not necessarily have names starting with .
The DOS and Windows environments refer to serial ports as COM ports: COM1, COM2,..etc.
Since the control signals for a serial port can be driven by any digital signal, some applications used the control lines of a serial port to monitor external devices, without exchanging serial data. A common commercial application of this principle was for some models of uninterruptible power supply which used the control lines to signal loss of power, low battery, and other status information. At least some Morse code training software used a code key connected to the serial port to simulate actual code use; the status bits of the serial port could be sampled very rapidly and at predictable times, making it possible for the software to decipher Morse code.
Serial computer mice may draw their operating power from the received data or control signals.
+ Common serial port speeds ! style=max-width:5em | Common applications |
Bell 101 modem | |
IBM 2741 terminal | |
Bell 103 modem or V.21 modem | |
Bell 202, Bell 212A, or V.22 modem | |
V.22bis modem | |
V.27ter modem | |
V.32 modem | |
V.32bis modem | |
MIDI port | |
V.90/V.92 modem | |
V.32bis modem with V.42bis compression | |
V.34 modem with V.42bis compression, low cost serial V.90/V.92 modem with V.42bis or V.44 compression | |
ISO 11898-3 CAN bus | |
Basic Rate Interface ISDN terminal adapter | |
LocalTalk, Econet, high end serial V.90/V.92 modem with V.42bis or V.44 compression | |
DMX512, stage lighting and effects network | |
Serial standards provide for many different operating speeds as well as adjustments to the protocol to account for different operating conditions. The most well-known options are speed, number of data bits per character, parity, and number of stop bits per character.
In modern serial ports using a UART integrated circuit, all these settings can be software-controlled. Hardware from the 1980s and earlier may require setting switches or jumpers on a circuit board.
The configuration for serial ports designed to be connected to a PC has become a de facto standard, usually stated as 9600/8-N-1.
A standard series of rates is based on multiples of the rates for electromechanical ; some serial ports allow many arbitrary rates to be selected, but the speeds on both sides of the connection must match for data to be received correctly. Bit rates commonly supported include 75, 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600 and . Many of these standard modem bit rates are multiples of either (e.g., 19200, 38400, 76800) or (e.g., 57600, 115200). Crystal oscillators with a frequency of 1.843200 MHz are sold specifically for this purpose. This is 16 times the fastest bit rate, and the serial port circuit can easily divide this down to lower frequencies as required.
The capability to set a bit rate does not imply that a working connection will result. Not all bit rates are possible with all serial ports. Some special-purpose protocols such as MIDI for musical instrument control, use serial data rates other than the teleprinter standards. Some serial port implementations can automatically choose a bit rate by observing what a connected device is sending and synchronizing to it.
Most serial communications designs send the data bits within each byte least significant bit first. Also possible, but rarely used, is most significant bit first; this was used, for example, by the IBM 2741 printing terminal. The order of bits is not usually configurable within the serial port interface but is defined by the host system. To communicate with systems that require a different bit ordering than the local default, local software can re-order the bits within each byte just before sending and just after receiving.
The parity bit in each character can be set to one of the following:
Aside from uncommon applications that use the last bit (usually the 9th) for some form of addressing or special signaling, mark or space parity is uncommon, as it adds no error detection information.
Odd parity is more useful than even parity since it ensures that at least one state transition occurs in each character, which makes it more reliable at detecting errors like those that could be caused by serial port speed mismatches. The most common parity setting, however, is none, with error detection handled by a communication protocol.
To allow detection of messages damaged by line noise, electromechanical teleprinters were arranged to print a special character when received data contained a parity error.
The abbreviation is usually given together with the line speed in bits per second, as in "9600–8-N-1". The speed (or baud rate) includes bits for Data frame (stop bits, parity, etc.), thus the effective data rate is lower than the baud rate. For 8-N-1 encoding, only 80% of the bits are available for data (for every eight bits of data, ten bits are sent over the serial link — one start bit, the eight data bits, and the one stop bit).
Hardware handshaking is done with extra signals, often the RS-232 RTS/CTS or DTR/DSR signal circuits. RTS and CTS are used to control data flow, signaling, for instance, when a buffer is almost full. Per the RS-232 standard and its successors, DTR and DSR are used to signal that equipment is present and powered up so are usually asserted at all times. However, non-standard implementations exist, for example, printers that use DTR as flow control.
Software handshaking is done for example with ASCII control characters XON/XOFF to control the flow of data. The XON and XOFF characters are sent by the receiver to the sender to control when the sender will send data, that is, these characters go in the opposite direction to the data being sent. The system starts in the sending allowed state. When the receiver's buffers approach capacity, the receiver sends the XOFF character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an XON character to tell the sender to resume transmission. It is an example of in-band signaling, where control information is sent over the same channel as its data.
The advantage of hardware handshaking is that it can be extremely fast, it works independently of imposed meaning such as ASCII on the transferred data and it is stateless. Its disadvantage is that it requires more hardware and cabling, and both ends of the connection must support the hardware handshaking protocol used.
The advantage of software handshaking is that it can be done with absent or incompatible hardware handshaking circuits and cabling. The disadvantage, common to all in-band control signaling, is that it introduces complexities in ensuring that control messages get through even when data messages are blocked, and data can never be mistaken for control signals. The former is normally dealt with by the operating system or device driver; the latter normally by ensuring that control codes are escape sequence (such as in the Kermit protocol) or omitted by design (such as in ANSI terminal control).
If no handshaking is employed, an overrun receiver might simply fail to receive data from the transmitter. Approaches for preventing this include reducing the speed of the connection so that the receiver can always keep up, increasing the size of data buffer so it can keep up averaged over a longer time, using delays after time-consuming operations (e.g. in termcap) or employing a mechanism to resend data which has not been received correctly (e.g. TCP).
|
|